package edu.ccut.saturn.basecomponent.database.impl.mysql;

import edu.ccut.saturn.basecomponent.database.IDatabaseAttribute;

/**
 * mysql中所使用的字段类型,数值,时间,字符
 * @author zjh
 * 
 */
public class MysqlAttribute implements IDatabaseAttribute{
	public static final String BIT = "BIT";
	public static final String TINYINT = "TINYINT";
	public static final String BOOL = "BOOL";//
	public static final String BOOLEAN = "BOOLEAN";//
	public static final String SMALLINT = "SMALLINT";
	public static final String MEDIUMINT = "MEDIUMINT";
	public static final String INT = "INT";
	public static final String INTEGER = "INTEGER";
	public static final String BIGINT = "BIGINT";
	public static final String FLOAT = "FLOAT";
	public static final String DOUBLE = "DOUBLE";
	public static final String DECIMAL = "DECIMAL";
	
	public static final String DATE = "DATE";
	public static final String DATETIME = "DATETIME";
	public static final String TIMESTAMP = "TIMESTAMP";
	public static final String TIME = "TIME";
	public static final String YEAR = "YEAR";
	
	public static final String CHAR = "CHAR";
	public static final String VARCHAR = "VARCHAR";
	public static final String BLOB = "BLOB";
	public static final String TEXT = "TEXT";
	public static final String MEDIUMBLOB = "MEDIUMBLOB";
	public static final String MEDIUMTEXT = "MEDIUMTEXT";
	public static final String LONGBLOB = "LONGBLOB";
	public static final String LONGTEXT = "LONGTEXT";

	/**
	 * 目前不知道有没有被使用
	 * 
	 * @param type
	 * @return 如果type是数字类型返回"",否则返回"'"
	 */
//	public static String quote(String type) {
//		if (BIT.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type)
//				|| MEDIUMINT.equals(type)|| INT.equals(type)|| INTEGER.equals(type)
//				|| BIGINT.equals(type)|| FLOAT.equals(type)|| DOUBLE.equals(type)
//				|| DECIMAL.equals(type)) {
//			return "";
//		} else {
//			return "'";
//		}
//	}

	/**
	 * 是否是数字类型
	 * @author zjh
	 * @param type
	 * @return
	 */
	public boolean isNumber(String type) {
		if (BIT.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type)
				|| MEDIUMINT.equals(type)|| INT.equals(type)|| INTEGER.equals(type)
				|| BIGINT.equals(type)|| FLOAT.equals(type)|| DOUBLE.equals(type)
				|| DECIMAL.equals(type)) {
			return true;
		}
		return false;
	}

	/**
	 * 是否是大数据类型,目前收录6个列类型,TINYTEXT,TINYBLOB,没有被使用
	 * @author zjh
	 * @param type
	 * @return
	 */
	public boolean isLOB(String type) {
		if (BLOB.equalsIgnoreCase(type) || TEXT.equalsIgnoreCase(type)
				|| MEDIUMBLOB.equalsIgnoreCase(type) || MEDIUMTEXT.equalsIgnoreCase(type)
				|| LONGBLOB.equalsIgnoreCase(type) || LONGTEXT.equalsIgnoreCase(type)) {
			return true;
		}
		return false;
	}

}
